package com.czl.module_user.fragment

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.czl.base.adapter.ViewPagerFmAdapter
import com.czl.base.base.BaseFragment
import com.czl.base.config.AppConstants
import com.czl.base.route.RouteCenter
import com.czl.module_user.BR
import com.czl.module_user.R
import com.czl.module_user.databinding.FragmentMyScoreBinding
import com.czl.module_user.viewmodel.MyScoreViewModel
import me.yokeyword.fragmentation.SupportFragment

/**
 *
 * @Description:我的评价
 * @Author: XCH
 * @CreateDate: 2022/1/6 14:17
 */
@Route(path = AppConstants.Router.User.F_MY_SCORE)
class MyScoreFragment : BaseFragment<FragmentMyScoreBinding, MyScoreViewModel>() {

    override fun initContentView(): Int {
        return R.layout.fragment_my_score
    }

    override fun initVariableId(): Int {
        return BR.viewModel
    }

    override fun initData() {
        viewModel.tvTitle.set("业主评价")
        hiddenBottomShadow()

        var noCompleteFragment =
            RouteCenter.navigate(AppConstants.Router.User.F_SCORE_LIST, Bundle().apply {
                putString(AppConstants.BundleKey.OWNER_STATE, "0")
            }) as SupportFragment
        var completeFragment =
            RouteCenter.navigate(AppConstants.Router.User.F_SCORE_LIST, Bundle().apply {
                putString(AppConstants.BundleKey.OWNER_STATE, "1")
            }) as SupportFragment
        var fragments = arrayListOf(noCompleteFragment, completeFragment)
        binding.viewPager.apply {
            adapter = ViewPagerFmAdapter(childFragmentManager, lifecycle, fragments)
        }
    }

    override fun initViewObservable() {
        viewModel.uc.tabChangeLiveEvent.observe(this, {
            binding.viewPager.setCurrentItem(it, false)
        })
        viewModel.uc.pageChangeLiveEvent.observe(this, {
            binding.tabLayout.currentTab = it
        })
    }
}